package com.ysqcould.web.controller.allocation;


import com.ysqcould.allocation.domain.WxConfig;
import com.ysqcould.allocation.service.IWxConfigService;
import com.ysqcould.common.annotation.Log;
import com.ysqcould.common.core.controller.BaseController;
import com.ysqcould.common.core.domain.AjaxResult;
import com.ysqcould.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * 微信小程序配置Controller
 * 
 * @author ruoyi
 * @date 2022-06-29
 */
@RestController
@RequestMapping("/allocation/wxConfig")
public class WxConfigController extends BaseController
{
    @Autowired
    private IWxConfigService wxConfigService;

    /**
     * 查询微信小程序配置列表
     */
    @PreAuthorize("@ss.hasPermi('allocation:wxconfig:list')")
    @GetMapping("/list")
    public AjaxResult list(WxConfig wxConfig)
    {
        wxConfig.setAsId(getUserId());
        WxConfig config = wxConfigService.selectWxConfigList(wxConfig);
        return AjaxResult.success(config);
    }

    /**
     * 获取微信小程序配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('allocation:wxconfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(wxConfigService.selectWxConfigById(id));
    }

    /**
     * 新增微信小程序配置
     */
    @PreAuthorize("@ss.hasPermi('allocation:wxconfig:add')")
    @Log(title = "微信小程序配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WxConfig wxConfig)
    {
        wxConfig.setAsId(getUserId());
        return toAjax(wxConfigService.insertWxConfig(wxConfig));
    }

    /**
     * 修改微信小程序配置
     */
    @PreAuthorize("@ss.hasPermi('allocation:wxconfig:edit')")
    @Log(title = "微信小程序配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WxConfig wxConfig)
    {
        return toAjax(wxConfigService.updateWxConfig(wxConfig));
    }

    /**
     * 删除微信小程序配置
     */
    @PreAuthorize("@ss.hasPermi('allocation:wxconfig:remove')")
    @Log(title = "微信小程序配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wxConfigService.deleteWxConfigByIds(ids));
    }
}
